package com.simon.bio;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by changf on 2017/7/10.
 */
public class MyServer {

    void startServer()throws Exception{
        ServerSocket server=new ServerSocket(8999);
        System.out.println("server start");
        while(true) {
            Socket socket = server.accept();
            InputStreamReader inputStreamReader = new InputStreamReader(socket.getInputStream());
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String inputString = bufferedReader.readLine();
            System.out.println("server read:" + inputString);

            PrintWriter printWriter = new PrintWriter(socket.getOutputStream(),true);
            printWriter.println("server输出响应:ok" + inputString);
        }
    }
}
